<!DOCTYPE html>
<!-- saved from url=(0067)http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script async="" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/analytics.js"></script>
<meta charset="utf-8">
<title>使用CodeDom提高ORM性能 - Net.AfritXia - 博客园</title>
<link type="text/css" rel="stylesheet" href="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/blog-common.css">
<link id="MainCss" type="text/css" rel="stylesheet" href="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/bundle-LessIsMoreRight.css">
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/afritxia2008/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/afritxia2008/rsd.xml">
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/afritxia2008/wlwmanifest.xml">
<script type="text/javascript" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/encoder.js"></script><script async="" type="text/javascript" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/gpt.js"></script><script src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/jquery.js" type="text/javascript"></script>  
<script type="text/javascript">var currentBlogApp = 'afritxia2008', cb_enable_mathjax=false;</script>
<script src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/blog-common.js" type="text/javascript"></script>
<style type="text/css">#yddContainer{display:block;font-family:Microsoft YaHei;position:relative;width:100%;height:100%;top:-4px;left:-4px;font-size:12px;border:1px solid}#yddTop{display:block;height:22px}#yddTopBorderlr{display:block;position:static;height:17px;padding:2px 28px;line-height:17px;font-size:12px;color:#5079bb;font-weight:bold;border-style:none solid;border-width:1px}#yddTopBorderlr .ydd-sp{position:absolute;top:2px;height:0;overflow:hidden}.ydd-icon{left:5px;width:17px;padding:0px 0px 0px 0px;padding-top:17px;background-position:-16px -44px}.ydd-close{right:5px;width:16px;padding-top:16px;background-position:left -44px}#yddKeyTitle{float:left;text-decoration:none}#yddMiddle{display:block;margin-bottom:10px}.ydd-tabs{display:block;margin:5px 0;padding:0 5px;height:18px;border-bottom:1px solid}.ydd-tab{display:block;float:left;height:18px;margin:0 5px -1px 0;padding:0 4px;line-height:18px;border:1px solid;border-bottom:none}.ydd-trans-container{display:block;line-height:160%}.ydd-trans-container a{text-decoration:none;}#yddBottom{position:absolute;bottom:0;left:0;width:100%;height:22px;line-height:22px;overflow:hidden;background-position:left -22px}.ydd-padding010{padding:0 10px}#yddWrapper{color:#252525;z-index:10001;background:url(chrome-extension://eopjamdnofihpioajgfdikhhbobonhbb/ab20.png);}#yddContainer{background:#fff;border-color:#4b7598}#yddTopBorderlr{border-color:#f0f8fc}#yddWrapper .ydd-sp{background-image:url(chrome-extension://eopjamdnofihpioajgfdikhhbobonhbb/ydd-sprite.png)}#yddWrapper a,#yddWrapper a:hover,#yddWrapper a:visited{color:#50799b}#yddWrapper .ydd-tabs{color:#959595}.ydd-tabs,.ydd-tab{background:#fff;border-color:#d5e7f3}#yddBottom{color:#363636}#yddWrapper{min-width:250px;max-width:400px;}</style><meta name="chromesniffer" id="chromesniffer_meta" content="{&quot;jQuery&quot;:&quot;1.7&quot;}"><script type="text/javascript" src="chrome-extension://homgcnaoacgigpkkljjjekpignblkeae/detector.js"></script><script async="" type="text/javascript" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/pubads_impl_50.js"></script><script type="text/javascript" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/osd.js"></script></head>
<body>
<a name="top"></a>

<div id="home">
<div id="header">
	<div id="blogTitle">
		
<!--done-->
<div class="title"><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/afritxia2008/">Net.AfritXia</a></div>
<div class="subtitle">.NET, JAVA, PHP, WebGame, 软件架构设计, 技术管理, 追求阅读体验</div>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li id="nav_sitehome"><a id="MyLinks1_HomeLink" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
<li id="nav_myhome"><a id="MyLinks1_MyHomeLink" class="menu" href="http://www.cnblogs.com/afritxia2008/">首页</a></li>
<li id="nav_q"><a class="menu" href="http://q.cnblogs.com/">博问</a></li>
<li id="nav_ing"><a class="menu" href="http://home.cnblogs.com/ing/">闪存</a></li>
<li id="nav_newpost"><a id="MyLinks1_NewPostLink" class="menu" rel="nofollow" href="http://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li>
<li id="nav_contact"><a id="MyLinks1_ContactLink" class="menu" rel="nofollow" href="http://space.cnblogs.com/msg/send/Net.AfritXia">联系</a></li>
<li id="nav_rss"><a id="MyLinks1_Syndication" class="menu" href="http://www.cnblogs.com/afritxia2008/rss">订阅</a>
<!--<a id="MyLinks1_XMLLink" class="aHeaderXML" href="http://www.cnblogs.com/afritxia2008/rss"><img src="http://www.cnblogs.com/images/xml.gif" alt="订阅" /></a>--></li>
<li id="nav_admin"><a id="MyLinks1_Admin" class="menu" rel="nofollow" href="http://i.cnblogs.com/">管理</a></li>
</ul>

		<div class="blogStats">
			
			
<!--done-->
随笔-13&nbsp;
文章-1&nbsp;
评论-42&nbsp;

			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		

<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/使用CodeDom提高ORM性能 - Net.AfritXia - 博客园.htm">使用CodeDom提高ORM性能</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body"><p><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;"><span style="font-family: 宋体;">下载本文代码：<span style="font-family: Verdana;"><a href="http://files.cnblogs.com/afritxia2008/WebTest.rar">http://files.cnblogs.com/afritxia2008/WebTest.rar</a>（请使用 Visual Studio 2008 打开）</span><br>
<br>
　　在进行讨论之前，我假设读者已经了解</span>.NET<span style="font-family: 宋体;">反射、自定义属性、</span>CodeDom<span style="font-family: 宋体;">这些技术。并接触过</span>ORM<span style="font-family: 宋体;">框架源码，如果对</span>ORM<span style="font-family: 宋体;">并不了解，可以参考：</span></span></span></span><a href="http://www.cnblogs.com/xdesigner/archive/2008/06/24/1228702.html"><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;">http://www.cnblogs.com/xdesigner/archive/2008/06/24/1228702.html</span></span></span></a><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;"><span style="font-family: 宋体;">。在这篇文章中，我们主要讨论通过</span>CodeDom<span style="font-family: 宋体;">提高</span>ORM<span style="font-family: 宋体;">读取数据的性能问题。</span></span></span></span></p>
<p><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;">　　ORM<span style="font-family: 宋体;">（</span>Object/Relation Mapping<span style="font-family: 宋体;">对象</span>-<span style="font-family: 宋体;">关系数据库映射）其中的一个功能是将数据源数据赋值给实体。实现方法是利用自定义属性和</span>.NET</span></span></span><span style="font-family: 宋体;"><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;">反射机制。例如：<br>
<br>
</span></span></span></span></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;LWordEntity<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img id="Codehighlighter1_27_568_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_27_568_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_27_568_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_27_568_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img id="Codehighlighter1_31_79_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_31_79_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_31_79_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_31_79_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;获取或设置留言&nbsp;ID<br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">&nbsp;6</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[DataColumn(ColumnName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">LWordUID</span><span style="color: #800000;">"</span><span style="color: #000000;">)]<br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;LWordUID<br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #000000;"><img id="Codehighlighter1_143_158_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_143_158_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_143_158_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_143_158_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span style="color: #008000;"><br>
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img id="Codehighlighter1_162_209_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_162_209_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_162_209_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_162_209_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">13</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;获取或设置发送用户<br>
</span><span style="color: #008080;">14</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">15</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[DataColumn(ColumnName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">PostUser</span><span style="color: #800000;">"</span><span style="color: #000000;">)]<br>
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;PostUser<br>
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="Codehighlighter1_276_291_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_276_291_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_276_291_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_276_291_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span style="color: #008000;"><br>
</span><span style="color: #008080;">19</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img id="Codehighlighter1_295_342_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_295_342_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_295_342_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_295_342_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">22</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;获取或设置发送时间<br>
</span><span style="color: #008080;">23</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">24</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[DataColumn(ColumnName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">PostTime</span><span style="color: #800000;">"</span><span style="color: #000000;">)]<br>
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;DateTime&nbsp;PostTime<br>
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img id="Codehighlighter1_411_426_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_411_426_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_411_426_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_411_426_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span style="color: #008000;"><br>
</span><span style="color: #008080;">28</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img id="Codehighlighter1_430_477_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_430_477_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_430_477_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_430_477_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">31</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;获取或设置文本内容<br>
</span><span style="color: #008080;">32</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">33</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[DataColumn(ColumnName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">TextContent</span><span style="color: #800000;">"</span><span style="color: #000000;">)]<br>
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;TextContent<br>
</span><span style="color: #008080;">35</span><span style="color: #000000;"><img id="Codehighlighter1_550_565_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_550_565_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_550_565_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_550_565_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span style="color: #008000;"><br>
</span><span style="color: #008080;">37</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p><span style="font-size: 9pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-no-proof: yes;" lang="EN-US"><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;"><br>
<span style="font-size: 10pt; font-family: 新宋体;"><span style="font-size: 9pt; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-no-proof: yes;" lang="EN-US"><span><span><span style="font-size: 10pt;">　　DataColumn</span></span></span></span><span style="font-size: 9pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-no-proof: yes; mso-ascii-font-family: &#39;Courier New&#39;; mso-hansi-font-family: &#39;Courier New&#39;; mso-bidi-font-family: &#39;Courier New&#39;;"><span style="font-size: 10pt;"><span><span>是自定义的属性类，代码并不复杂所以在这里也就省略了。接下来需要通过反射读取自定义属性，并赋值。代码如下：</span></span></span></span></span></span></span></span></span><span style="font-size: 9pt; font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-no-proof: yes; mso-ascii-font-family: &#39;Courier New&#39;; mso-hansi-font-family: &#39;Courier New&#39;; mso-bidi-font-family: &#39;Courier New&#39;;"><span style="font-size: 10pt;"><br>
<br>
</span></span></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;PutEntityProperties(</span><span style="color: #0000ff;">object</span><span style="color: #000000;">&nbsp;objEntity,&nbsp;DbDataReader&nbsp;dr)<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img id="Codehighlighter1_69_1100_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_69_1100_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_69_1100_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_69_1100_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取实体类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;objType&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;objEntity.GetType();<br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;6</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取属性信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;propInfoList&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;objType.GetProperties();<br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(propInfoList&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">||</span><span style="color: #000000;">&nbsp;propInfoList.Length&nbsp;</span><span style="color: #000000;">&lt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">foreach</span><span style="color: #000000;">&nbsp;(PropertyInfo&nbsp;propInfo&nbsp;</span><span style="color: #0000ff;">in</span><span style="color: #000000;">&nbsp;propInfoList)<br>
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="Codehighlighter1_312_1097_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_312_1097_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_312_1097_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_312_1097_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">object</span><span style="color: #000000;">[]&nbsp;colAttrList&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;propInfo.GetCustomAttributes(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(DataColumnAttribute),&nbsp;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;未标记&nbsp;DataColumn&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">17</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(colAttrList&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">||</span><span style="color: #000000;">&nbsp;colAttrList.Length&nbsp;</span><span style="color: #000000;">&lt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">continue</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取数据列属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">21</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataColumnAttribute&nbsp;colAttr&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;colAttrList[</span><span style="color: #800080;">0</span><span style="color: #000000;">]&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;DataColumnAttribute;<br>
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;ordinal&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">try</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img id="Codehighlighter1_620_690_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_620_690_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_620_690_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_620_690_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取数据列序号</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">28</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ordinal&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;dr.GetOrdinal(colAttr.ColumnName);<br>
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">&nbsp;(Exception&nbsp;ex)<br>
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img id="Codehighlighter1_718_848_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_718_848_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_718_848_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_718_848_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;MappingException(<br>
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.Format(</span><span style="color: #800000;">"</span><span style="color: #800000;">{0}&nbsp;未找到该数据列(&nbsp;Cannot&nbsp;Found&nbsp;this&nbsp;Column&nbsp;{0}&nbsp;)</span><span style="color: #800000;">"</span><span style="color: #000000;">,&nbsp;colAttr.ColumnName),&nbsp;ex);<br>
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">35</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取数据列值</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">37</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">object</span><span style="color: #000000;">&nbsp;objValue&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;dr.GetValue(ordinal);<br>
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(objValue&nbsp;</span><span style="color: #0000ff;">is</span><span style="color: #000000;">&nbsp;DBNull)<br>
</span><span style="color: #008080;">40</span><span style="color: #000000;"><img id="Codehighlighter1_937_1010_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_937_1010_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_937_1010_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_937_1010_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">41</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;将&nbsp;null&nbsp;值设置到属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">42</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;propInfo.SetValue(objEntity,&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">,&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">43</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">44</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">45</span><span style="color: #000000;"><img id="Codehighlighter1_1022_1093_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1022_1093_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1022_1093_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1022_1093_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">46</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;将值设置到属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">47</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;propInfo.SetValue(objEntity,&nbsp;objValue,&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">48</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">49</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">50</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">51</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p><span style="font-family: 宋体;"><br>
<span style="font-size: 10pt; font-family: 新宋体;"><span>　　以上代码实现了读取数据源数据并向实体赋值的功能。但这样做速度非常慢，因为每读取一条数据库记录，每读取一个数据字段并向实体赋值的时候，都必须进行一次反射操作。数据量越大，且数据字段或实体属性越多，那么速度就越慢！在以上代码中，对实体的反射操作，其目的就是赋值。可以被等价的语句所替代：<br>
　　　　</span><span>entity.Prop = dr[“Porp”];<br>
</span><span>用简单的赋值语句肯定要比反射的速度快很多，而大数据量和多数据库字段对其影响也不是很大。不过需要注意的是因为每一个实体的具体属性不相同，所以赋值过程也是不相同的。例如：<br>
</span>News<span>实体赋值代码：<br>
</span></span></span><span style="font-family: 宋体;"><br>
</span></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;PutEntityProperties(NewsEntity&nbsp;entity,&nbsp;DbDataReader&nbsp;dr)<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img id="Codehighlighter1_77_514_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_77_514_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_77_514_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_77_514_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;新闻&nbsp;ID</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.ID&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">ID</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;标题</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;6</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.Title&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">Title</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;摘要</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.Summary&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">Summary</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;发送用户</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.PostUser&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">PostUser</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;发送时间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">12</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.PostTime&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(DateTime)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">PostTime</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;文本内容</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">14</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.TextContent&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">TextContent</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p>
<span style="font-size: 10.5pt; font-family: &#39;Times New Roman&#39;; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;" lang="EN-US"><span style="font-size: 10pt; font-family: 新宋体;"><span style="font-size: 10.5pt; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;" lang="EN-US">User</span><span style="font-size: 10.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;">实体赋值代码：</span></span></span><br>
<br></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;PutEntityProperties(UserEntity&nbsp;entity,&nbsp;DbDataReader&nbsp;dr)<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img id="Codehighlighter1_77_446_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_77_446_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_77_446_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_77_446_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;用户&nbsp;ID</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.ID&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">ID</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;用户名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;6</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.UserName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">UserName</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;密码</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.UserPass&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">UserPass</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;电子邮件</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.EMail&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">EMail</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;注册时间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">12</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.RegisterTime&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;(DateTime)dr[</span><span style="color: #800000;">"</span><span style="color: #800000;">RegisterTime</span><span style="color: #800000;">"</span><span style="color: #000000;">];<br>
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>
<br>
<span style="font-size: 10pt; font-family: 新宋体;">　　News<span>与</span>User<span>所具备的属性不同，所以赋值过程，也不相同！但毫无疑问，使用直接赋值的方法是速度最快的！<span style="text-decoration: underline;">试想一下，假如在做反射的时候不是直接赋值，而是根据自定义属性，动态的生成赋值代码，编译以后临时保存起来。那么以后再进行赋值操作的时候，直接调用这个编译好的赋值代码，不就可以大大提升程序性能了么？</span>有没有一个办法可以自动建立类似上面这样的代码呢？我们可以考虑使用反射和</span>CodeDom<span>技术。<br>
<br>
</span></span><span style="font-family: 宋体;"><br>
</span></p><div align="center"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/WebTest.jpg" border="0"></div>
<br>
<br>
<span style="font-size: 10.5pt; font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;"><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;"><span style="font-family: 宋体;">　　</span></span></span></span>首先为了解决不同实体的不同的赋值过程，我们需要建立一个接口：</span><span style="font-size: 10.5pt; font-family: &#39;Times New Roman&#39;; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;" lang="EN-US">IEntityPropertyPutter</span><span style="font-size: 10.5pt; font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;">。在该接口中的</span><span style="font-size: 10.5pt; font-family: &#39;Times New Roman&#39;; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;" lang="EN-US">PutEntityProperties</span><span style="font-size: 10.5pt; font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;">函数负责真正的赋值逻辑。在赋值的过程中会调用</span><span style="font-size: 10.5pt; font-family: &#39;Times New Roman&#39;; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;" lang="EN-US">IEntityPropertyPutter</span><span style="font-size: 10.5pt; font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt;">的具体实现类的实例。具体类图如下：</span><br>
<br>
&nbsp;
<div align="center"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/Class_Diagram__Class__SQLHelper.jpg" border="0"><br>
<br>
</div>
<p><span style="font-family: 新宋体;"><span style="font-family: 新宋体;"><span style="font-size: 10pt;"><span style="font-family: 宋体;">　　</span></span></span></span><span style="font-size: 10pt; font-family: 新宋体;">EntityPropertyPutterFactory<span>工厂类负责创建</span>IEntityPropertyPutter<span>接口具体实现类的实例。首先该工厂类会从缓存中获取</span>IEntityPropertyPutter<span>接口实例，如果该实例为空（还没有被创建），那么该工厂类会调用</span>EntityPropertyPutterMaker<span>构建者类创建实例（<span style="font-family: Verdana;">Entity实体类本身也可以直接实现IEntityPropertyPutter接口，来加快程序的运行速度</span>）。在构建者内部会动态创建新的程序集（</span>Assembly<span>），在该程序集中只存在一个</span>QuicklyPutter<span>类。在</span>QuicklyPutter<span>类中描述了具体的赋值逻辑，这些逻辑编码则是根据反射和</span>CodeDom<span>完成的。最后交由</span>CodeDom<span>动态编译……<span style="font-family: Verdana;">根据不同的实体，所创建的程序集也不相同。所编译成功的程序集是临时存放在内存里，所以QuicklyPutter类用白色表示。</span>具体代码如下：<br>
</span></span><span style="font-family: 宋体;"><br>
</span></p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System;<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Collections.Generic;<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Data.Common;<br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Reflection;<br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;6</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;Net.AfritXia.Data.Mapping;<br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;Net.AfritXia.Data<br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #000000;"><img id="Codehighlighter1_162_1122_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_162_1122_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_162_1122_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_162_1122_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">partial</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;SQLHelper<br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img id="Codehighlighter1_190_1120_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_190_1120_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_190_1120_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_190_1120_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;PutEntityProperties</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(T&nbsp;entity,&nbsp;DbDataReader&nbsp;dr)&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="Codehighlighter1_274_1117_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_274_1117_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_274_1117_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_274_1117_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取设置器</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">15</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;putter&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;EntityPropertyPutterFactory.Create</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(entity,&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.IncludeDebugInformation);<br>
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(putter&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;NullReferenceException(</span><span style="color: #800000;">@"</span><span style="color: #800000;">设置器为空(&nbsp;Null&nbsp;Putter&nbsp;)</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">try</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img id="Codehighlighter1_557_654_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_557_654_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_557_654_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_557_654_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;设置实体属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">23</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;putter.PutEntityProperties(entity,&nbsp;dr);<br>
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">&nbsp;(Exception&nbsp;ex)<br>
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img id="Codehighlighter1_700_1113_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_700_1113_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_700_1113_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_700_1113_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;errorMessage&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义异常信息格式</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">30</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorMessage&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">@"</span><span style="color: #800000;">从数据库字段{0}&nbsp;读取值并赋给属性{1}&nbsp;时出错(实体类型:&nbsp;{2})</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;格式化信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">32</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorMessage&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;String.Format(errorMessage,&nbsp;putter.CurrentDBColName,&nbsp;putter.CurrentPropName,&nbsp;putter.EntityTypeName);<br>
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;抛出异常</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">35</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Exception(errorMessage,&nbsp;ex);<br>
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">37</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">40</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p><span style="font-family: 宋体;">设置器工厂类EntityPropertyPutterFactory：</span></p>
<p>&nbsp;</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System;<br>
</span><span style="color: #008080;">&nbsp;2</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Collections;<br>
</span><span style="color: #008080;">&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Reflection;<br>
</span><span style="color: #008080;">&nbsp;4</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;Net.AfritXia.Data<br>
</span><span style="color: #008080;">&nbsp;6</span><span style="color: #000000;"><img id="Codehighlighter1_94_1763_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_94_1763_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_94_1763_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_94_1763_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;7</span><span style="color: #000000;"><img id="Codehighlighter1_100_152_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_100_152_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_100_152_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_100_152_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;8</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;实体属性设置器工厂类<br>
</span><span style="color: #008080;">&nbsp;9</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">10</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">internal</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">sealed</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;EntityPropertyPutterFactory<br>
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img id="Codehighlighter1_210_1761_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_210_1761_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_210_1761_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_210_1761_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;设置器字典</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">13</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">static</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">readonly</span><span style="color: #000000;">&nbsp;Hashtable&nbsp;g_putterHash&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;Hashtable.Synchronized(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Hashtable());<br>
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img id="Codehighlighter1_336_586_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_336_586_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_336_586_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_336_586_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">16</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;创建实体属性设置器<br>
</span><span style="color: #008080;">17</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">18</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;typeparam&nbsp;name="T"&gt;</span><span style="color: #008000;">实体类型模版</span><span style="color: #808080;">&lt;/typeparam&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">19</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="fromEntity"&gt;</span><span style="color: #008000;">实体</span><span style="color: #808080;">&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">20</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="includeDebugInfo"&gt;</span><span style="color: #008000;">是否包含调试信息</span><span style="color: #808080;">&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">21</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">22</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">static</span><span style="color: #000000;">&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;Create</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(T&nbsp;fromEntity,&nbsp;</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">&nbsp;includeDebugInfo)&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img id="Codehighlighter1_704_1755_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_704_1755_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_704_1755_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_704_1755_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(fromEntity&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;如果实体本身已经实现了&nbsp;IEntityPropertyPutter&lt;T&gt;&nbsp;接口,&nbsp;<br>
</span><span style="color: #008080;">28</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;则直接返回</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">29</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(fromEntity&nbsp;</span><span style="color: #0000ff;">is</span><span style="color: #000000;">&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;(IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">)fromEntity;<br>
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;putter&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取字典关键字</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">35</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;hashKey&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;fromEntity.GetType().FullName;<br>
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">37</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(g_putterHash.ContainsKey(hashKey))<br>
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img id="Codehighlighter1_1168_1288_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1168_1288_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1168_1288_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1168_1288_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;从字典中获取设置器</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">40</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;putter&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;g_putterHash[hashKey]&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">41</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">42</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">43</span><span style="color: #000000;"><img id="Codehighlighter1_1318_1717_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1318_1717_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1318_1717_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1318_1717_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">44</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EntityPropertyPutterMaker&nbsp;maker&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">45</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">46</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建构建器</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">47</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maker&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;EntityPropertyPutterMaker();<br>
</span><span style="color: #008080;">48</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;是否包含调试信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">49</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maker.IncludeDebugInformation&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;includeDebugInfo;<br>
</span><span style="color: #008080;">50</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">51</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;新建应用程序集</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">52</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;putter&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;maker.Make</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();<br>
</span><span style="color: #008080;">53</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;保存应用设置器到字典</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">54</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_putterHash.Add(hashKey,&nbsp;putter);<br>
</span><span style="color: #008080;">55</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">56</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">57</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;putter;<br>
</span><span style="color: #008080;">58</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">59</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">60</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">}</span></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>构建器EntityPropertyPutterMaker：<br>
<br>
</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div><span style="color: #008080;">&nbsp;&nbsp;1</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><span style="color: #0000ff;">#undef</span><span style="color: #000000;">&nbsp;_Debug&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;用于调试</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;&nbsp;2</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;&nbsp;3</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System;<br>
</span><span style="color: #008080;">&nbsp;&nbsp;4</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.CodeDom;<br>
</span><span style="color: #008080;">&nbsp;&nbsp;5</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Collections.Specialized;<br>
</span><span style="color: #008080;">&nbsp;&nbsp;6</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.CodeDom.Compiler;<br>
</span><span style="color: #008080;">&nbsp;&nbsp;7</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Data.Common;<br>
</span><span style="color: #008080;">&nbsp;&nbsp;8</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">#if</span><span style="color: #000000;">&nbsp;_Debug</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;&nbsp;9</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.IO;<br>
</span><span style="color: #008080;">&nbsp;10</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;11</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;System.Reflection;<br>
</span><span style="color: #008080;">&nbsp;12</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;13</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;Microsoft.CSharp;<br>
</span><span style="color: #008080;">&nbsp;14</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;15</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">using</span><span style="color: #000000;">&nbsp;Net.AfritXia.Data.Mapping;<br>
</span><span style="color: #008080;">&nbsp;16</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;17</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/None.gif" align="top"></span><span style="color: #0000ff;">namespace</span><span style="color: #000000;">&nbsp;Net.AfritXia.Data<br>
</span><span style="color: #008080;">&nbsp;18</span><span style="color: #000000;"><img id="Codehighlighter1_303_15925_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_303_15925_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_303_15925_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_303_15925_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;19</span><span style="color: #000000;"><img id="Codehighlighter1_309_360_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_309_360_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_309_360_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_309_360_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;20</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建实体属性设置器<br>
</span><span style="color: #008080;">&nbsp;21</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">&nbsp;22</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">internal</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">sealed</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&nbsp;EntityPropertyPutterMaker<br>
</span><span style="color: #008080;">&nbsp;23</span><span style="color: #000000;"><img id="Codehighlighter1_416_15923_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_416_15923_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_416_15923_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_416_15923_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;24</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;默认名称空间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;25</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;DefaultNamespace&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">Net.AfritXia.Data._AutoCode</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">&nbsp;26</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;QuicklyPutter&nbsp;类名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;27</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;QuicklyPutterClassName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">QuicklyPutter</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">&nbsp;28</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;29</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;包含调试信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;30</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">&nbsp;m_includeDebugInfo&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">&nbsp;31</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;32</span><span style="color: #000000;"><img id="Codehighlighter1_692_850_Closed_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top"><img id="Codehighlighter1_692_850_Open_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_692_850_Closed_Text" style="background-color: #ffffff; border: #808080 1px solid;">类构造器</span><span id="Codehighlighter1_692_850_Open_Text" style="display: none;"><span style="color: #0000ff;">#region</span><span style="color: #000000;">&nbsp;类构造器</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;33</span><span style="color: #000000;"><img id="Codehighlighter1_713_769_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_713_769_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_713_769_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_713_769_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;34</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;类默认构造器<br>
</span><span style="color: #008080;">&nbsp;35</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">&nbsp;36</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;EntityPropertyPutterMaker()<br>
</span><span style="color: #008080;">&nbsp;37</span><span style="color: #000000;"><img id="Codehighlighter1_820_831_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_820_831_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_820_831_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_820_831_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;38</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;39</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">#endregion</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;40</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;41</span><span style="color: #000000;"><img id="Codehighlighter1_860_923_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_860_923_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_860_923_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_860_923_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;42</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;设置或获取是否包含调试信息<br>
</span><span style="color: #008080;">&nbsp;43</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span></span><br>
<span style="color: #008080;">&nbsp;44</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">&nbsp;IncludeDebugInformation<br>
</span><span style="color: #008080;">&nbsp;45</span><span style="color: #000000;"><img id="Codehighlighter1_975_1172_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_975_1172_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_975_1172_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_975_1172_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;46</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">set</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;47</span><span style="color: #000000;"><img id="Codehighlighter1_1005_1069_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1005_1069_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1005_1069_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1005_1069_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;48</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.m_includeDebugInfo&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;value;<br>
</span><span style="color: #008080;">&nbsp;49</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;50</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;51</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">get</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;52</span><span style="color: #000000;"><img id="Codehighlighter1_1099_1162_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1099_1162_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1099_1162_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1099_1162_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;53</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.m_includeDebugInfo;<br>
</span><span style="color: #008080;">&nbsp;54</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;55</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;56</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;57</span><span style="color: #000000;"><img id="Codehighlighter1_1182_1324_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1182_1324_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1182_1324_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_1182_1324_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;58</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建实体属性设置器<br>
</span><span style="color: #008080;">&nbsp;59</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;60</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;typeparam&nbsp;name="T"&gt;</span><span style="color: #008000;">实体类型模版</span><span style="color: #808080;">&lt;/typeparam&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;61</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">&nbsp;62</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;Make</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">()&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;63</span><span style="color: #000000;"><img id="Codehighlighter1_1398_3636_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_1398_3636_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_1398_3636_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_1398_3636_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">&nbsp;64</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建一个可编译的单元</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;65</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeCompileUnit&nbsp;compileUnit&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeCompileUnit();<br>
</span><span style="color: #008080;">&nbsp;66</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建名称空间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;67</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeNamespace&nbsp;namespace_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeNamespace();<br>
</span><span style="color: #008080;">&nbsp;68</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;69</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeTypeDeclaration&nbsp;class_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeClass</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();<br>
</span><span style="color: #008080;">&nbsp;70</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建&nbsp;PutEntityProperties&nbsp;方法</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;71</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberMethod&nbsp;method_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeMethod</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();<br>
</span><span style="color: #008080;">&nbsp;72</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;73</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加方法到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;74</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_code.Members.Add(method_code);<br>
</span><span style="color: #008080;">&nbsp;75</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加类到名称空间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;76</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;namespace_code.Types.Add(class_code);<br>
</span><span style="color: #008080;">&nbsp;77</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加名称空间到编译单元</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;78</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compileUnit.Namespaces.Add(namespace_code);<br>
</span><span style="color: #008080;">&nbsp;79</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;80</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建&nbsp;C#&nbsp;编译器</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;81</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeDomProvider&nbsp;provider&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;CodeDomProvider.CreateProvider(</span><span style="color: #800000;">"</span><span style="color: #800000;">CSharp</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">&nbsp;82</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建编译参数</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;83</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CompilerParameters&nbsp;options&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CompilerParameters();<br>
</span><span style="color: #008080;">&nbsp;84</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;85</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加对&nbsp;System.dll&nbsp;的引用</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;86</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.ReferencedAssemblies.Add(</span><span style="color: #800000;">"</span><span style="color: #800000;">System.dll</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">&nbsp;87</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加对&nbsp;System.Data.dll&nbsp;的引用</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;88</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.ReferencedAssemblies.Add(</span><span style="color: #800000;">"</span><span style="color: #800000;">System.Data.dll</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">&nbsp;89</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加对该项目的引用</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;90</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.ReferencedAssemblies.Add(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.GetType().Assembly.Location);<br>
</span><span style="color: #008080;">&nbsp;91</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加对实体项目的引用</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;92</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.ReferencedAssemblies.Add(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(T).Assembly.Location);<br>
</span><span style="color: #008080;">&nbsp;93</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;只在内存中编译</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">&nbsp;94</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.GenerateInMemory&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">true</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">&nbsp;95</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;96</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #0000ff;">#if</span><span style="color: #000000;">&nbsp;_Debug</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">&nbsp;97</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;srcFilePath&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">&nbsp;98</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">&nbsp;99</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srcFilePath&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">@"</span><span style="color: #800000;">C:\{0}_{1}.cs</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">100</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srcFilePath&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;String.Format(srcFilePath,&nbsp;</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(T).Name,&nbsp;QuicklyPutterClassName);<br>
</span><span style="color: #008080;">101</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">102</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;源文件输出流</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">103</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamWriter&nbsp;srcOutput&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;StreamWriter(srcFilePath,&nbsp;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">104</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;写出源文件</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">105</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;provider.GenerateCodeFromCompileUnit(compileUnit,&nbsp;srcOutput,&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeGeneratorOptions());<br>
</span><span style="color: #008080;">106</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">107</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srcOutput.Flush();<br>
</span><span style="color: #008080;">108</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;srcOutput.Close();<br>
</span><span style="color: #008080;">109</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #0000ff;">#endif</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">110</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">111</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;编译并获取编译结果</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">112</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CompilerResults&nbsp;compileResult&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;provider.CompileAssemblyFromDom(options,&nbsp;compileUnit);<br>
</span><span style="color: #008080;">113</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">114</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;编译失败则抛出异常</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">115</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(compileResult.NativeCompilerReturnValue&nbsp;</span><span style="color: #000000;">!=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">116</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;Exception(</span><span style="color: #800000;">"</span><span style="color: #800000;">编译失败&nbsp;(&nbsp;Compile&nbsp;Failed&nbsp;)</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">117</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">118</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建设置器</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">119</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">object</span><span style="color: #000000;">&nbsp;putter&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;compileResult.CompiledAssembly.CreateInstance(DefaultNamespace&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">.</span><span style="color: #800000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;QuicklyPutterClassName);<br>
</span><span style="color: #008080;">120</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">121</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;(IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">)putter;<br>
</span><span style="color: #008080;">122</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">123</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">124</span><span style="color: #000000;"><img id="Codehighlighter1_3646_3735_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_3646_3735_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_3646_3735_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_3646_3735_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">125</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建可编译单元<br>
</span><span style="color: #008080;">126</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">127</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">128</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeCompileUnit&nbsp;MakeCompileUnit()<br>
</span><span style="color: #008080;">129</span><span style="color: #000000;"><img id="Codehighlighter1_3793_3872_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_3793_3872_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_3793_3872_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_3793_3872_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">130</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建一个可编译的单元</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">131</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeCompileUnit();<br>
</span><span style="color: #008080;">132</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">133</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">134</span><span style="color: #000000;"><img id="Codehighlighter1_3882_3970_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_3882_3970_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_3882_3970_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_3882_3970_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">135</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建名称空间<br>
</span><span style="color: #008080;">136</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">137</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">138</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeNamespace&nbsp;MakeNamespace()<br>
</span><span style="color: #008080;">139</span><span style="color: #000000;"><img id="Codehighlighter1_4024_4113_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_4024_4113_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_4024_4113_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_4024_4113_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">140</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建名称空间</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">141</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeNamespace(DefaultNamespace);<br>
</span><span style="color: #008080;">142</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">143</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">144</span><span style="color: #000000;"><img id="Codehighlighter1_4123_4223_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_4123_4223_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_4123_4223_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_4123_4223_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">145</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;QuicklyPutter&nbsp;类<br>
</span><span style="color: #008080;">146</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">147</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">148</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeTypeDeclaration&nbsp;MakeClass</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">()&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">149</span><span style="color: #000000;"><img id="Codehighlighter1_4298_4919_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_4298_4919_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_4298_4919_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_4298_4919_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">150</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义&nbsp;QuicklyPutter&nbsp;类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">151</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeTypeDeclaration&nbsp;class_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeTypeDeclaration(QuicklyPutterClassName);<br>
</span><span style="color: #008080;">152</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">153</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;令该类实现&nbsp;IEntityPropertyPutter&lt;T&gt;&nbsp;接口</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">154</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_code.BaseTypes.Add(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(IEntityPropertyPutter</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">155</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">156</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加&nbsp;EntityTypeName&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">157</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeEntityTypeNameProperty</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(class_code);<br>
</span><span style="color: #008080;">158</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加&nbsp;CurrentPropName&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">159</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeCurrentPropNameProperty(class_code);<br>
</span><span style="color: #008080;">160</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加&nbsp;CurrentDBColName&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">161</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeCurrentDBColNameProperty(class_code);<br>
</span><span style="color: #008080;">162</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">163</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;class_code;<br>
</span><span style="color: #008080;">164</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">165</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">166</span><span style="color: #000000;"><img id="Codehighlighter1_4929_5133_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_4929_5133_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_4929_5133_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_4929_5133_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">167</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;EntityTypeName&nbsp;属性<br>
</span><span style="color: #008080;">168</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">169</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;typeparam&nbsp;name="T"&gt;</span><span style="color: #008000;">实体类型模版</span><span style="color: #808080;">&lt;/typeparam&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">170</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="targetClass"&gt;</span><span style="color: #008000;">目标代码</span><span style="color: #808080;">&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">171</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">172</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeTypeDeclaration&nbsp;MakeEntityTypeNameProperty</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(CodeTypeDeclaration&nbsp;targetClass)&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">173</span><span style="color: #000000;"><img id="Codehighlighter1_5256_6418_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_5256_6418_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_5256_6418_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_5256_6418_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">174</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(targetClass&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">175</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;ArgumentNullException(</span><span style="color: #800000;">"</span><span style="color: #800000;">targetClass</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">176</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">177</span><span style="color: #000000;"><img id="Codehighlighter1_5372_5645_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_5372_5645_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_5372_5645_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_5372_5645_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;<br>
</span><span style="color: #008080;">178</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;以下代码将生成<br>
</span><span style="color: #008080;">179</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">180</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;public&nbsp;string&nbsp;EntityTypeName<br>
</span><span style="color: #008080;">181</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;{<br>
</span><span style="color: #008080;">182</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get<br>
</span><span style="color: #008080;">183</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: #008080;">184</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;实体类型名称字符串<br>
</span><span style="color: #008080;">185</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: #008080;">186</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;}<br>
</span><span style="color: #008080;">187</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">188</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">189</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">190</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">191</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;EntityTypeName&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">192</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberProperty&nbsp;entityTypeNameProp_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">193</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</span><span style="color: #008080;">194</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">195</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityTypeNameProp_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberProperty();<br>
</span><span style="color: #008080;">196</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为公共属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">197</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityTypeNameProp_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Public;<br>
</span><span style="color: #008080;">198</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;返回字符串类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">199</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityTypeNameProp_code.Type&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeTypeReference(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">200</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;属性名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">201</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityTypeNameProp_code.Name&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">EntityTypeName</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">202</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;返回语句</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">203</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityTypeNameProp_code.GetStatements.Add(<br>
</span><span style="color: #008080;">204</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMethodReturnStatement(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodePrimitiveExpression(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(T).Name)));<br>
</span><span style="color: #008080;">205</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">206</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加属性到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">207</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetClass.Members.Add(entityTypeNameProp_code);<br>
</span><span style="color: #008080;">208</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">209</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;targetClass;<br>
</span><span style="color: #008080;">210</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">211</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">212</span><span style="color: #000000;"><img id="Codehighlighter1_6428_6583_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_6428_6583_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_6428_6583_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_6428_6583_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">213</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;CurrentPropName&nbsp;属性<br>
</span><span style="color: #008080;">214</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">215</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="targetClass"&gt;</span><span style="color: #008000;">目标类代码</span><span style="color: #808080;">&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">216</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">217</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeTypeDeclaration&nbsp;MakeCurrentPropNameProperty(CodeTypeDeclaration&nbsp;targetClass)<br>
</span><span style="color: #008080;">218</span><span style="color: #000000;"><img id="Codehighlighter1_6688_8429_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_6688_8429_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_6688_8429_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_6688_8429_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">219</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(targetClass&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">220</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;ArgumentNullException(</span><span style="color: #800000;">"</span><span style="color: #800000;">targetClass</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">221</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">222</span><span style="color: #000000;"><img id="Codehighlighter1_6804_7136_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_6804_7136_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_6804_7136_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_6804_7136_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;<br>
</span><span style="color: #008080;">223</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;以下代码将生成<br>
</span><span style="color: #008080;">224</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">225</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;private&nbsp;string&nbsp;m_currPropName;<br>
</span><span style="color: #008080;">226</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">227</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;public&nbsp;string&nbsp;CurrentPropName&nbsp;<br>
</span><span style="color: #008080;">228</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;{<br>
</span><span style="color: #008080;">229</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get<br>
</span><span style="color: #008080;">230</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: #008080;">231</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;this.m_currPropName;<br>
</span><span style="color: #008080;">232</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: #008080;">233</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;}<br>
</span><span style="color: #008080;">234</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">235</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">236</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">237</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;变量名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">238</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;VaribleName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">m_currPropName</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">239</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">240</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;m_currPropName</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">241</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;m_currPropName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">242</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">243</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建字段</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">244</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currPropName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberField();<br>
</span><span style="color: #008080;">245</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为私有成员</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">246</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currPropName_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Private;<br>
</span><span style="color: #008080;">247</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建变量</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">248</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currPropName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberField(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">),&nbsp;VaribleName);<br>
</span><span style="color: #008080;">249</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">250</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加成员到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">251</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetClass.Members.Add(m_currPropName_code);<br>
</span><span style="color: #008080;">252</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">253</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;CurrentPropName</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">254</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberProperty&nbsp;currPropName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">255</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</span><span style="color: #008080;">256</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">257</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currPropName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberProperty();<br>
</span><span style="color: #008080;">258</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为公共属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">259</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currPropName_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Public;<br>
</span><span style="color: #008080;">260</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;返回字符串类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">261</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currPropName_code.Type&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeTypeReference(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">262</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;属性名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">263</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currPropName_code.Name&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">CurrentPropName</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">264</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;get&nbsp;返回语句</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">265</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currPropName_code.GetStatements.Add(<br>
</span><span style="color: #008080;">266</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMethodReturnStatement(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeFieldReferenceExpression(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeThisReferenceExpression(),&nbsp;VaribleName)));<br>
</span><span style="color: #008080;">267</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">268</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加属性到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">269</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetClass.Members.Add(currPropName_code);<br>
</span><span style="color: #008080;">270</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">271</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;targetClass;<br>
</span><span style="color: #008080;">272</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">273</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">274</span><span style="color: #000000;"><img id="Codehighlighter1_8439_8593_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_8439_8593_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_8439_8593_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_8439_8593_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">275</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;CurrentDBColName&nbsp;属性<br>
</span><span style="color: #008080;">276</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">277</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="targetClass"&gt;</span><span style="color: #008000;">父级类</span><span style="color: #808080;">&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">278</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">279</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeTypeDeclaration&nbsp;MakeCurrentDBColNameProperty(CodeTypeDeclaration&nbsp;targetClass)<br>
</span><span style="color: #008080;">280</span><span style="color: #000000;"><img id="Codehighlighter1_8699_10424_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_8699_10424_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_8699_10424_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_8699_10424_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">281</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(targetClass&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">282</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;ArgumentNullException(</span><span style="color: #800000;">"</span><span style="color: #800000;">targetClass</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">283</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">284</span><span style="color: #000000;"><img id="Codehighlighter1_8815_9150_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_8815_9150_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_8815_9150_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_8815_9150_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;<br>
</span><span style="color: #008080;">285</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;以下代码将生成<br>
</span><span style="color: #008080;">286</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">287</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;private&nbsp;string&nbsp;m_currDBColName;<br>
</span><span style="color: #008080;">288</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">289</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;public&nbsp;string&nbsp;CurrentDBColName&nbsp;<br>
</span><span style="color: #008080;">290</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;{<br>
</span><span style="color: #008080;">291</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get<br>
</span><span style="color: #008080;">292</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
</span><span style="color: #008080;">293</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;this.m_currDBColName;<br>
</span><span style="color: #008080;">294</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
</span><span style="color: #008080;">295</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;}<br>
</span><span style="color: #008080;">296</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">297</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">298</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">299</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;变量名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">300</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">const</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;VaribleName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">m_currDBColName</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">301</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;m_currDBColName</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">302</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;m_currDBColName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">303</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">304</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建字段</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">305</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currDBColName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberField();<br>
</span><span style="color: #008080;">306</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为私有成员</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">307</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currDBColName_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Private;<br>
</span><span style="color: #008080;">308</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建变量</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">309</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_currDBColName_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberField(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">),&nbsp;VaribleName);<br>
</span><span style="color: #008080;">310</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">311</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加成员到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">312</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetClass.Members.Add(m_currDBColName_code);<br>
</span><span style="color: #008080;">313</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">314</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;CurrentDBColName</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">315</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberProperty&nbsp;currDBCol_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">316</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">317</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">318</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currDBCol_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberProperty();<br>
</span><span style="color: #008080;">319</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为公共属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">320</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currDBCol_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Public;<br>
</span><span style="color: #008080;">321</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;返回字符串类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">322</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currDBCol_code.Type&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeTypeReference(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">323</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;属性名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">324</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currDBCol_code.Name&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">CurrentDBColName</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">325</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;get&nbsp;返回语句</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">326</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currDBCol_code.GetStatements.Add(<br>
</span><span style="color: #008080;">327</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMethodReturnStatement(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeFieldReferenceExpression(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeThisReferenceExpression(),&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">m_currDBColName</span><span style="color: #800000;">"</span><span style="color: #000000;">)));<br>
</span><span style="color: #008080;">328</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">329</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加属性到类</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">330</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetClass.Members.Add(currDBCol_code);<br>
</span><span style="color: #008080;">331</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">332</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;targetClass;<br>
</span><span style="color: #008080;">333</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">334</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">335</span><span style="color: #000000;"><img id="Codehighlighter1_10434_10632_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_10434_10632_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_10434_10632_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_10434_10632_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">336</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;PutEntityProperties&nbsp;方法<br>
</span><span style="color: #008080;">337</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">338</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;typeparam&nbsp;name="T"&gt;&lt;/typeparam&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">339</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="fromEntity"&gt;&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">340</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">341</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeMemberMethod&nbsp;MakeMethod</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">T</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">()&nbsp;</span><span style="color: #0000ff;">where</span><span style="color: #000000;">&nbsp;T&nbsp;:&nbsp;</span><span style="color: #0000ff;">class</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">342</span><span style="color: #000000;"><img id="Codehighlighter1_10705_12660_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_10705_12660_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_10705_12660_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_10705_12660_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">343</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;PutObjectProperties&nbsp;方法</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">344</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberMethod&nbsp;method_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">345</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</span><span style="color: #008080;">346</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建方法</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">347</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeMemberMethod();<br>
</span><span style="color: #008080;">348</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;定义为公共方法</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">349</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code.Attributes&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;MemberAttributes.Public;<br>
</span><span style="color: #008080;">350</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;返回类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">351</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code.ReturnType&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeTypeReference(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(</span><span style="color: #0000ff;">void</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">352</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;方法名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">353</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code.Name&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">PutEntityProperties</span><span style="color: #800000;">"</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">354</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加参数&nbsp;entity</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">355</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code.Parameters.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeParameterDeclarationExpression(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(T),&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">entity</span><span style="color: #800000;">"</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">356</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;添加参数&nbsp;dr</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">357</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code.Parameters.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeParameterDeclarationExpression(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(DbDataReader),&nbsp;</span><span style="color: #800000;">"</span><span style="color: #800000;">dr</span><span style="color: #800000;">"</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">358</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">359</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取实体类型</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">360</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;objType&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(T);<br>
</span><span style="color: #008080;">361</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">362</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取&nbsp;DataTable&nbsp;属性标记</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">363</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">object</span><span style="color: #000000;">[]&nbsp;tabAttrList&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;objType.GetCustomAttributes(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(DataTableAttribute),&nbsp;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">364</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">365</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(tabAttrList&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">||</span><span style="color: #000000;">&nbsp;tabAttrList.Length&nbsp;</span><span style="color: #000000;">&lt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">366</span><span style="color: #000000;"><img id="Codehighlighter1_11660_11845_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_11660_11845_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_11660_11845_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_11660_11845_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">367</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;MappingException(<br>
</span><span style="color: #008080;">368</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.Format(</span><span style="color: #800000;">@"</span><span style="color: #800000;">类&nbsp;{0}&nbsp;未标记&nbsp;DataTable&nbsp;属性&nbsp;(&nbsp;Unlabeled&nbsp;[DataTable]&nbsp;Attribute&nbsp;On&nbsp;Class&nbsp;{0}&nbsp;)</span><span style="color: #800000;">"</span><span style="color: #000000;">,&nbsp;objType.Name));<br>
</span><span style="color: #008080;">369</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">370</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">371</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取属性信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">372</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertyInfo[]&nbsp;propInfoList&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;objType.GetProperties();<br>
</span><span style="color: #008080;">373</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">374</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(propInfoList&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">||</span><span style="color: #000000;">&nbsp;propInfoList.Length&nbsp;</span><span style="color: #000000;">&lt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">375</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">376</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">377</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">foreach</span><span style="color: #000000;">&nbsp;(PropertyInfo&nbsp;propInfo&nbsp;</span><span style="color: #0000ff;">in</span><span style="color: #000000;">&nbsp;propInfoList)<br>
</span><span style="color: #008080;">378</span><span style="color: #000000;"><img id="Codehighlighter1_12105_12617_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_12105_12617_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_12105_12617_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_12105_12617_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">379</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">object</span><span style="color: #000000;">[]&nbsp;colAttrList&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;propInfo.GetCustomAttributes(</span><span style="color: #0000ff;">typeof</span><span style="color: #000000;">(DataColumnAttribute),&nbsp;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">380</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">381</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;未标记&nbsp;DataColumn&nbsp;属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">382</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(colAttrList&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">||</span><span style="color: #000000;">&nbsp;colAttrList.Length&nbsp;</span><span style="color: #000000;">&lt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #800080;">0</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">383</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">continue</span><span style="color: #000000;">;<br>
</span><span style="color: #008080;">384</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">385</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;获取数据列属性</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">386</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataColumnAttribute&nbsp;colAttr&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;colAttrList[</span><span style="color: #800080;">0</span><span style="color: #000000;">]&nbsp;</span><span style="color: #0000ff;">as</span><span style="color: #000000;">&nbsp;DataColumnAttribute;<br>
</span><span style="color: #008080;">387</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">388</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建方法内容</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">389</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.MakeMethodContent(method_code,&nbsp;propInfo,&nbsp;colAttr,&nbsp;</span><span style="color: #0000ff;">this</span><span style="color: #000000;">.IncludeDebugInformation);<br>
</span><span style="color: #008080;">390</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">391</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">392</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;method_code;<br>
</span><span style="color: #008080;">393</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">394</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">395</span><span style="color: #000000;"><img id="Codehighlighter1_12670_12959_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_12670_12959_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_12670_12959_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_12670_12959_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">396</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;构建&nbsp;PutEntityProperties&nbsp;方法内容<br>
</span><span style="color: #008080;">397</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;/summary&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">398</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="targetMethod"&gt;&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">399</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="prop"&gt;&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">400</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="attr"&gt;&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">401</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;param&nbsp;name="includeDebugInfo"&gt;&lt;/param&gt;</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">402</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #808080;">///</span><span style="color: #008000;">&nbsp;</span><span style="color: #808080;">&lt;returns&gt;&lt;/returns&gt;</span></span><br>
<span style="color: #008080;">403</span><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">private</span><span style="color: #000000;">&nbsp;CodeMemberMethod&nbsp;MakeMethodContent(CodeMemberMethod&nbsp;targetMethod,&nbsp;PropertyInfo&nbsp;prop,&nbsp;DataColumnAttribute&nbsp;attr,&nbsp;</span><span style="color: #0000ff;">bool</span><span style="color: #000000;">&nbsp;includeDebugInfo)<br>
</span><span style="color: #008080;">404</span><span style="color: #000000;"><img id="Codehighlighter1_13117_15917_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_13117_15917_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_13117_15917_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_13117_15917_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">405</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(targetMethod&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">406</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;ArgumentNullException(</span><span style="color: #800000;">"</span><span style="color: #800000;">targetMethod</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">407</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">408</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(attr&nbsp;</span><span style="color: #000000;">==</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>
</span><span style="color: #008080;">409</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">throw</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;ArgumentNullException(</span><span style="color: #800000;">"</span><span style="color: #800000;">attr</span><span style="color: #800000;">"</span><span style="color: #000000;">);<br>
</span><span style="color: #008080;">410</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">411</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;实体变量名称&nbsp;entity</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">412</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;varEntityName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;targetMethod.Parameters[</span><span style="color: #800080;">0</span><span style="color: #000000;">].Name;<br>
</span><span style="color: #008080;">413</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;数据源变量名称&nbsp;dr</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">414</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;varDrName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;targetMethod.Parameters[</span><span style="color: #800080;">1</span><span style="color: #000000;">].Name;<br>
</span><span style="color: #008080;">415</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">416</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;entity&nbsp;属性名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">417</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;varEntityPropName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;String.Format(</span><span style="color: #800000;">@"</span><span style="color: #800000;">{0}.{1}</span><span style="color: #800000;">"</span><span style="color: #000000;">,&nbsp;varEntityName,&nbsp;prop.Name);<br>
</span><span style="color: #008080;">418</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;dr&nbsp;属性名称</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">419</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">string</span><span style="color: #000000;">&nbsp;varDrPropName&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;String.Format(</span><span style="color: #800000;">@"</span><span style="color: #800000;">{0}[""{1}""]</span><span style="color: #800000;">"</span><span style="color: #000000;">,&nbsp;varDrName,&nbsp;attr.Name);<br>
</span><span style="color: #008080;">420</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">421</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建变量</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">422</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeVariableReferenceExpression&nbsp;entityProp_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(varEntityPropName);<br>
</span><span style="color: #008080;">423</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;创建值</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">424</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeVariableReferenceExpression&nbsp;dr_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(varDrPropName);<br>
</span><span style="color: #008080;">425</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">426</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;包含调试信息</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">427</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(includeDebugInfo)<br>
</span><span style="color: #008080;">428</span><span style="color: #000000;"><img id="Codehighlighter1_14063_14611_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_14063_14611_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_14063_14611_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_14063_14611_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">429</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;this.m_currPropName&nbsp;=&nbsp;entity.Prop</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">430</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetMethod.Statements.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeAssignStatement(<br>
</span><span style="color: #008080;">431</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(</span><span style="color: #800000;">"</span><span style="color: #800000;">this.m_currPropName</span><span style="color: #800000;">"</span><span style="color: #000000;">),<br>
</span><span style="color: #008080;">432</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodePrimitiveExpression(prop.Name)));<br>
</span><span style="color: #008080;">433</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">434</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;this.m_currDBColName&nbsp;=&nbsp;attributeName</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">435</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetMethod.Statements.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeAssignStatement(<br>
</span><span style="color: #008080;">436</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(</span><span style="color: #800000;">"</span><span style="color: #800000;">this.m_currDBColName</span><span style="color: #800000;">"</span><span style="color: #000000;">),<br>
</span><span style="color: #008080;">437</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodePrimitiveExpression(attr.Name)));<br>
</span><span style="color: #008080;">438</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">439</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">440</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(attr.IsNullable)<br>
</span><span style="color: #008080;">441</span><span style="color: #000000;"><img id="Codehighlighter1_14658_15604_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_14658_15604_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_14658_15604_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_14658_15604_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">442</span><span style="color: #000000;"><img id="Codehighlighter1_14676_14894_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_14676_14894_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_14676_14894_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;">/**/</span><span id="Codehighlighter1_14676_14894_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">&nbsp;<br>
</span><span style="color: #008080;">443</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;以下代码生成的是条件判断代码<br>
</span><span style="color: #008080;">444</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">445</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;if&nbsp;(dr["<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif">"]&nbsp;!=&nbsp;DBNull.Value)&nbsp;{<br>
</span><span style="color: #008080;">446</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entity.Prop&nbsp;=&nbsp;dr["<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif">"];<br>
</span><span style="color: #008080;">447</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;}<br>
</span><span style="color: #008080;">448</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;<br>
</span><span style="color: #008080;">449</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">*/</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">450</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">451</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeConditionStatement&nbsp;if_code&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeConditionStatement();<br>
</span><span style="color: #008080;">452</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">453</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;if&nbsp;(dr["<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif">"]&nbsp;!=&nbsp;DBNull.Value)</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">454</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if_code.Condition&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeBinaryOperatorExpression(<br>
</span><span style="color: #008080;">455</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(varDrPropName),<br>
</span><span style="color: #008080;">456</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeBinaryOperatorType.IdentityInequality,<br>
</span><span style="color: #008080;">457</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeVariableReferenceExpression(</span><span style="color: #800000;">"</span><span style="color: #800000;">System.DBNull.Value</span><span style="color: #800000;">"</span><span style="color: #000000;">));<br>
</span><span style="color: #008080;">458</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">459</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;entity.Prop&nbsp;=&nbsp;dr["<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif">"];</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">460</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if_code.TrueStatements.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeAssignStatement(<br>
</span><span style="color: #008080;">461</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityProp_code,<br>
</span><span style="color: #008080;">462</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeCastExpression(prop.PropertyType,&nbsp;dr_code)));<br>
</span><span style="color: #008080;">463</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">464</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetMethod.Statements.Add(if_code);<br>
</span><span style="color: #008080;">465</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">466</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>
</span><span style="color: #008080;">467</span><span style="color: #000000;"><img id="Codehighlighter1_15634_15873_Open_Image" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_15634_15873_Closed_Image" style="display: none;" onclick="code_collapse_toggle(this);" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ContractedSubBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="Codehighlighter1_15634_15873_Closed_Text" style="display: none; background-color: #ffffff; border: #808080 1px solid;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif"></span><span id="Codehighlighter1_15634_15873_Open_Text"><span style="color: #000000;">{<br>
</span><span style="color: #008080;">468</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000;">//</span><span style="color: #008000;">&nbsp;entity.Prop&nbsp;=&nbsp;dr["<img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/dot.gif">"];</span><span style="color: #008000;"><br>
</span><span style="color: #008080;">469</span><span style="color: #008000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"></span><span style="color: #000000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targetMethod.Statements.Add(</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeAssignStatement(<br>
</span><span style="color: #008080;">470</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;entityProp_code,<br>
</span><span style="color: #008080;">471</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">new</span><span style="color: #000000;">&nbsp;CodeCastExpression(prop.PropertyType,&nbsp;dr_code)));<br>
</span><span style="color: #008080;">472</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">473</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top"><br>
</span><span style="color: #008080;">474</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InBlock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&nbsp;targetMethod;<br>
</span><span style="color: #008080;">475</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">476</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedSubBlockEnd.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000;"><br>
</span><span style="color: #008080;">477</span><span style="color: #000000;"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/ExpandedBlockEnd.gif" align="top">}</span></span><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/copycode.gif" alt="复制代码"></a></span></div></div>
<br>
<p class="MsoNormal"><span style="font-family: 宋体; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;;"><span style="font-family: 新宋体;"><span style="font-size: 10pt; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;;">代码时序图如下：<br>
</span></span><br>
</span></p>
<p></p>
&nbsp;
<div align="center"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/Sequence_Diagram__Sequence__PutEntityProperty__PutEntityProperty__PutEntityProperty.jpg" border="0" style="width: 796.359375px;"></div>
<p class="MsoNormal" style="font-size: 10pt; font-family: 新宋体;"><span style="font-family: 宋体; mso-ascii-font-family: &#39;Times New Roman&#39;; mso-hansi-font-family: &#39;Times New Roman&#39;;">具体代码可以参考：<br>
</span><span lang="EN-US">Net.AfritXia.Data/IEntityPropertyPutter.cs<br>
</span><span lang="EN-US">Net.AfritXia.Data/EntityPropertyPutterFactory.cs<br>
</span><span lang="EN-US">Net.AfritXia.Data/EntityPropertyPutterMaker.cs<br>
</span><span lang="EN-US">TestProj/UnitTest_Putter.cs（可以运行该测试文件）</span></p></div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag">标签: <a href="http://www.cnblogs.com/afritxia2008/tag/SQLHelper/">SQLHelper</a>, <a href="http://www.cnblogs.com/afritxia2008/tag/CodeDom/">CodeDom</a>, <a href="http://www.cnblogs.com/afritxia2008/tag/ORM/">ORM</a>, <a href="http://www.cnblogs.com/afritxia2008/tag/Reflection/">Reflection</a></div>
<div id="blog_post_info"><div id="green_channel">
绿色通道：
<a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(1236860,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
<a id="green_channel_follow" onclick="c_follow();" href="javascript:void(0);">关注我</a>
<a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a><a id="green_channel_contact" href="http://space.cnblogs.com/msg/send/Net.AfritXia" target="_blank">与我联系</a>
<a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/icon_weibo_24.png" alt=""></a>
</div>
<div id="author_profile">
<div id="author_profile_info" class="author_profile_info">
<a href="http://home.cnblogs.com/u/afritxia2008/" target="_blank"><img src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/u35735.png" class="author_avatar" alt=""></a>
<div id="author_profile_detail" class="author_profile_info">
<a href="http://home.cnblogs.com/u/afritxia2008/">Net.AfritXia</a><br>
<a href="http://home.cnblogs.com/u/afritxia2008/followees">关注 - 6</a><br>
<a href="http://home.cnblogs.com/u/afritxia2008/followers">粉丝 - 15</a>
</div>
</div>
<div class="clear"></div>
<div id="author_profile_honor"></div>
<div id="author_profile_follow">
    <a href="javascript:void(0);" onclick="c_follow();return false;">+加关注</a>
</div>
</div>
<div id="div_digg">										
    <div class="diggit" onclick="votePost(1236860,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
	<div class="buryit" onclick="votePost(1236860,&#39;Bury&#39;)"> 
		<span class="burynum" id="bury_count">0</span>
	</div>
	<div class="clear"></div>	
	<div class="diggword" id="digg_tips">
    (请您对文章做出评价)
    </div>	
</div>
</div>
<div class="clear"></div>
<div id="post_next_prev"><a href="http://www.cnblogs.com/afritxia2008/archive/2008/06/27/1231070.html" class="p_n_p_prefix">« </a> 上一篇：<a href="http://www.cnblogs.com/afritxia2008/archive/2008/06/27/1231070.html" title="发布于2008-06-27 13:41">在线用户统计与命令模式</a><br><a href="http://www.cnblogs.com/afritxia2008/archive/2010/03/13/1684917.html" class="p_n_p_prefix">» </a> 下一篇：<a href="http://www.cnblogs.com/afritxia2008/archive/2010/03/13/1684917.html" title="发布于2010-03-13 09:45">版本控制</a><br></div>
</div>


		</div>
		<div class="postDesc">posted @ <span id="post-date">2008-07-06 13:53</span> <a href="http://www.cnblogs.com/afritxia2008/">Net.AfritXia</a> 阅读(<span id="post_view_count">2653</span>) 评论(<span id="post_comment_count">13</span>)  <a href="http://i.cnblogs.com/EditPosts.aspx?postid=1236860" rel="nofollow">编辑</a> <a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#" onclick="AddToWz(1236860);return false;">收藏</a></div>
	</div>
	<script type="text/javascript">var allowComments=true,isLogined=true,cb_blogId=39299,cb_entryId=1236860,cb_blogApp=currentBlogApp,cb_blogUserGuid='e542420b-63cf-dd11-9e4d-001cf0cd104b',cb_entryCreatedDate='2008/7/6 13:53:00';loadViewCount(cb_entryId);</script>
	
</div><!--end: topics 文章、评论容器-->
<a name="!comments"></a><div id="blog-comments-placeholder"><div id="comments_pager_top"></div>
<!--done-->
<div class="feedback_area_title">评论列表</div>
<div class="feedbackNoItems"></div>
	

		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246211,&#39;4Bhhuxr6VybJGlpNS5huWJae4bDeuWCD3tJdFaG0cgOLjtcNuJeVEw==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246211,&#39;4Bhhuxr6VybJGlpNS5huWJae4bDeuWCD3tJdFaG0cgOLjtcNuJeVEw==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246211" class="layer">#1楼</a><a name="1246211" id="comment_anchor_1246211"></a>  <span class="comment_date">2008-07-06 14:10</span> <a id="a_comment_author_1246211" href="http://www.cnblogs.com/RunDeep/" target="_blank">stillwater</a> <a href="http://msg.cnblogs.com/msg/send/stillwater" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246211" class="blog_comment_body">有点意思，仔细再看一遍</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1246211,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1246211,&#39;Bury&#39;,this)">反对(0)</a></div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246213,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246213,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246213" class="layer">#2楼</a><a name="1246213" id="comment_anchor_1246213"></a>  <span class="comment_date">2008-07-06 14:19</span> <a id="ctl00_CommentList_NameLink_1" href="http://basilwang.cnblogs.com/" target="_blank">BAsil</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246213" class="blog_comment_body">不错</div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246214,&#39;jKARw4aidfaBShtz6HTruMWCO27a0JnIsahejRe3BY41Zhl8GxWgAA==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246214,&#39;jKARw4aidfaBShtz6HTruMWCO27a0JnIsahejRe3BY41Zhl8GxWgAA==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246214" class="layer">#3楼</a><a name="1246214" id="comment_anchor_1246214"></a>  <span class="comment_date">2008-07-06 14:20</span> <a id="a_comment_author_1246214" href="http://www.cnblogs.com/killkill/" target="_blank">killkill</a> <a href="http://msg.cnblogs.com/msg/send/killkill" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246214" class="blog_comment_body">啊！ 
<br>ORM 之前加入预编译，很好地解决了性能问题
<br>顶！！！</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1246214,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1246214,&#39;Bury&#39;,this)">反对(0)</a></div><span id="comment_1246214_avatar" style="display:none;">http://pic.cnitblog.com/face/u17964.jpg?id=28112608</span>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246234,&#39;7V3kUO9fJNW5XFlQjFMpW+Cp6r64E/gNgenAGkiAEsMMc1FRd1ZlLg==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246234,&#39;7V3kUO9fJNW5XFlQjFMpW+Cp6r64E/gNgenAGkiAEsMMc1FRd1ZlLg==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246234" class="layer">#4楼</a><a name="1246234" id="comment_anchor_1246234"></a>  <span class="comment_date">2008-07-06 14:52</span> <a id="a_comment_author_1246234" href="http://www.cnblogs.com/codear/" target="_blank">Vokobo</a> <a href="http://msg.cnblogs.com/msg/send/Vokobo" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246234" class="blog_comment_body">这文章很不错，我就是这样做自定义表单和自定义流程的。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1246234,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1246234,&#39;Bury&#39;,this)">反对(0)</a></div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246406,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246406,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246406" class="layer">#5楼</a><a name="1246406" id="comment_anchor_1246406"></a>  <span class="comment_date">2008-07-06 22:13</span> <a id="ctl00_CommentList_NameLink_4" target="_blank">eee[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246406" class="blog_comment_body">这种做法很常见了。 .NET Framework 中深究下去，有不少地方干了这事，也因此会生成不少的临时assembly.</div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246538,&#39;V/dqXdQi03KJPW4bw/RblbuLu8ua83uBRcqdAzW4GElUl56KjCE04Q==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246538,&#39;V/dqXdQi03KJPW4bw/RblbuLu8ua83uBRcqdAzW4GElUl56KjCE04Q==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246538" class="layer">#6楼</a><a name="1246538" id="comment_anchor_1246538"></a>  <span class="comment_date">2008-07-07 06:59</span> <a id="a_comment_author_1246538" href="http://www.cnblogs.com/jyk/" target="_blank">金色海洋（jyk）阳光男孩</a> <a href="http://msg.cnblogs.com/msg/send/%e9%87%91%e8%89%b2%e6%b5%b7%e6%b4%8b%ef%bc%88jyk%ef%bc%89%e9%98%b3%e5%85%89%e7%94%b7%e5%ad%a9" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246538" class="blog_comment_body">搜藏。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1246538,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1246538,&#39;Bury&#39;,this)">反对(0)</a></div><span id="comment_1246538_avatar" style="display:none;">http://pic.cnitblog.com/face/u17148.jpg?id=03051207</span>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246547,&#39;RL0ASwkEuI+Ry3HjE3ohyuSUCNTsZ0q80JLoTKrsSsj7A/aEe7mT9Q==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246547,&#39;RL0ASwkEuI+Ry3HjE3ohyuSUCNTsZ0q80JLoTKrsSsj7A/aEe7mT9Q==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246547" class="layer">#7楼</a><a name="1246547" id="comment_anchor_1246547"></a>  <span class="comment_date">2008-07-07 07:59</span> <a id="a_comment_author_1246547" href="http://www.cnblogs.com/jintan/" target="_blank">代码乱了</a> <a href="http://msg.cnblogs.com/msg/send/%e4%bb%a3%e7%a0%81%e4%b9%b1%e4%ba%86" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246547" class="blog_comment_body">值得研究下</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1246547,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1246547,&#39;Bury&#39;,this)">反对(0)</a></div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246652,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246652,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246652" class="layer">#8楼</a><a name="1246652" id="comment_anchor_1246652"></a>  <span class="comment_date">2008-07-07 09:34</span> <a id="ctl00_CommentList_NameLink_7" target="_blank">路人乙[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246652" class="blog_comment_body">诺诺的问一句，如果在预编译时就生成这些代码，而不是在运行时才生成这些代码会怎么样？</div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246685,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246685,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246685" class="layer">#9楼</a><a name="1246685" id="comment_anchor_1246685"></a>  <span class="comment_date">2008-07-07 09:51</span> <a id="ctl00_CommentList_NameLink_8" target="_blank">coco熊[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246685" class="blog_comment_body">好文，顶一个，研究下</div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1246839,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1246839,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1246839" class="layer">#10楼</a><a name="1246839" id="comment_anchor_1246839"></a>  <span class="comment_date">2008-07-07 11:29</span> <a id="ctl00_CommentList_NameLink_9" target="_blank">afritxia2008[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1246839" class="blog_comment_body">从 Factory 和 Maker 的代码上来看，赋值代码是在程序运行期才被创建和编译的。我大致跟踪过这个过程，.net 会在一个临时目录里创建一个 .dll 文件，然后会将这个 .dll 文件读取到内存（应该是内存），并删除。
<br>
<br>eee网友，说的很对。我以前并没有深入研究过 .net，呵呵……</div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1252179,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1252179,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1252179" class="layer">#11楼</a><a name="1252179" id="comment_anchor_1252179"></a>  <span class="comment_date">2008-07-12 07:00</span> <a id="ctl00_CommentList_NameLink_10" href="http://www.cnitblog.com/r.aspx?url=http://www.ninv%235.c%235m" rel="nofllow" target="_blank">我爱博客园[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1252179" class="blog_comment_body">什么是orm。
<br>#1a hr#9f="<a href="http://www.ninv/#5.c#5m"#2温湿度变送器#1/a#2" target="_new" rel="nofollow">http://www.ninv#5.c#5m"#2温湿度变送器#1/a#2</a></div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1252184,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1252184,&#39;&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#1252184" class="layer">#12楼</a><a name="1252184" id="comment_anchor_1252184"></a>  <span class="comment_date">2008-07-12 07:10</span> <a id="ctl00_CommentList_NameLink_11" href="http://www.cnitblog.com/r.aspx?url=http://www.mai1718.cn" rel="nofllow" target="_blank">浮筒液位变送器[未注册用户]</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_1252184" class="blog_comment_body">什么是orm。*
<br><a href="http://www.mai1718.cn/" target="_new" rel="nofollow">http://www.mai1718.cn</a></div>
			</div>
		</div>
	
		<div class="feedbackItem">
			<div class="feedbackListSubtitle">
				<div class="feedbackManage">
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(2962043,&#39;dDpj+uL+CcSNW07yC+HTgWXQECiX9+fjkPbJYlP2o5x7Hxks3bVNtA==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(2962043,&#39;dDpj+uL+CcSNW07yC+HTgWXQECiX9+fjkPbJYlP2o5x7Hxks3bVNtA==&#39;)">引用</a></span>
				</div>
				<a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#2962043" class="layer">#13楼</a><a name="2962043" id="comment_anchor_2962043"></a><span id="comment-maxId" style="display:none;">2962043</span><span id="comment-maxDate" style="display:none;">2014/6/11 10:58:58</span>  <span class="comment_date">2014-06-11 10:58</span> <a id="a_comment_author_2962043" href="http://home.cnblogs.com/u/639650/" target="_blank">(￣o￣) . z Z</a> <a href="http://msg.cnblogs.com/msg/send/(%ef%bf%a3o%ef%bf%a3)+.+z+Z" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
			</div>
			<div class="feedbackCon">
				<div id="comment_body_2962043" class="blog_comment_body">呵呵，将从数据库处理完后的数据直接转化为一个实体，然后把他们放到一个实体集里面去，这样是很方便的。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(2962043,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(2962043,&#39;Bury&#39;,this)">反对(0)</a></div>
			</div>
		</div>
	<div id="comments_pager_bottom"></div></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" id="lnk_RefreshComments" onclick="return RefreshCommentList();">刷新评论</a><a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#" onclick="return RefreshPage();">刷新页面</a><a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#top">返回顶部</a></div>
<div id="comment_form_container"><div id="commentform_title">发表评论</div>
<span id="tip_comment" style="color:Red"></span>
<p>
昵称：<input type="text" id="tbCommentAuthor" class="author" disabled="disabled" size="50" value="window5549-accp">
</p>
<div class="commentbox_main">
<div class="commentbox_title">
<div class="commentbox_title_left">评论内容：</div>
<div class="commentbox_title_right">
<img id="ubb_quote" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/quote.gif" alt="引用" title="添加引用" onclick="insertUBB(&#39;tbCommentBody&#39;,&#39;quote&#39;)">
<img id="ubb_bold" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/b.png" alt="粗体" title="添加粗体" onclick="insertUBB(&#39;tbCommentBody&#39;,&#39;b&#39;)">
<img id="ubb_url" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/lk.png" alt="链接" title="添加链接" onclick="insertUbbUrl(&#39;tbCommentBody&#39;)">
<img id="ubb_indent" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/indent.png" alt="缩进" title="添加首行缩进" onclick="insertIndent(&#39;tbCommentBody&#39;)">
<img id="ubb_code" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/InsertCode.gif" alt="代码" title="添加代码" onclick="insertUbbCode()">
<img id="ubb_img" class="comment_icon" src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/img.gif" alt="图片" title="上传图片" onclick="OpenImageUploadWindow();">
</div>
</div>
<div class="clear"></div>
<textarea id="tbCommentBody" class="comment_textarea" rows="20" cols="50"></textarea>
</div>
<p id="commentbox_opt">
<input id="btn_comment_submit" type="button" class="comment_btn" value="提交评论">
<span id="span_comment_canceledit" style="display:none"><a href="javascript:void(0);" onclick="return CancelCommentEdit()">不改了</a></span>
<a href="javascript:void(0);" onclick="return logout();">注销</a>
        <a id="commentbox_opt_sub" href="javascript:void(0);" title="订阅后有新评论时会邮件通知您" onclick="commentManager.Subscribe()">订阅评论</a>
</p>
<p>
[使用Ctrl+Enter键快速提交]
</p>
<div style="display:none">
<span id="comment_edit_id"></span><span id="span_parentcomment_id"></span>
<span id="span_parent_id"></span>
<span id="span_comment_replyto"></span>
<span id="span_comment_posted"></span>
</div>
</div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="site_nav_under"><a href="http://www.imooc.com/view/31?from=cnblogs" target="_blank"><b>【免费课程】案例：图片展示特效</b></a><br><a href="http://zt.cnblogs.com/tingyun/" target="_blank">听云APP性能监测——终结移动App性能黑洞</a><br><a href="http://oneapm.com/events/ironman.html?hmsr=%E5%8D%9A%E5%AE%A2%E5%9B%AD&hmmd=%E6%96%87%E7%AB%A0%E5%86%85%E9%A1%B5%E6%96%87%E5%AD%97%E9%93%BE&hmpl=&hmkw=&hmci=" target="_blank">100%有礼！机械键盘、钢铁侠T恤免费拿！OneAPM送福利！</a><br><a href="http://www.rongcloud.cn/promotion/" target="_blank">融云，免费为你的App加入IM功能——让你的App“聊”起来！！</a></div>
<div id="opt_under_post"></div>
<script type="text/javascript">
    var enableGoogleAd = canShowAdsense(); var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];
    fixPostBodyFormat();
</script>
<div id="ad_under_post_holder">
<script type="text/javascript">
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function () {
        if (enableGoogleAd) {
            var gads = document.createElement('script');
            gads.async = true;
            gads.type = 'text/javascript';
            var useSSL = 'https:' == document.location.protocol;
            gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
            var node = document.getElementsByTagName('script')[0];
            node.parentNode.insertBefore(gads, node);
        }
    })();
</script>
<script type="text/javascript">
    try {
        if (enableGoogleAd) {
            googletag.cmd.push(function () {
                googletag.defineSlot('/1090369/cnblogs_blogpost_C1_sitehome', [300, 250], 'div-gpt-ad-1346480159711-0').addService(googletag.pubads());
                googletag.defineSlot('/1090369/cnblogs_blogpost_C2', [468, 60], 'div-gpt-ad-1410860226396-0').addService(googletag.pubads());
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
        };
    } catch (e) { }
</script>
<div id="google_ad_c1" class="c_ad_block">
    <div id="div-gpt-ad-1346480159711-0" style="width:300px; height:250px;">
    <script type="text/javascript">
        try {
            if (enableGoogleAd) {
                googletag.cmd.push(function () { googletag.display('div-gpt-ad-1346480159711-0'); });            
            } else {
                $('#div-gpt-ad-1346480159711-0').hide();
            }
    } catch (e) { }
    </script>
    <div id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0" name="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom;"></iframe></div><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__hidden__" name="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__hidden__" width="0" height="0" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom; visibility: hidden; display: none;"></iframe></div>
</div>
</div>
<div id="under_post_news"><div class="itnews c_ad_block"><b>最新IT新闻</b>:<br> ·  <a href="http://news.cnblogs.com/n/504624/" target="_blank">亚马逊为修正虚拟机漏洞重启EC2</a><br> ·  <a href="http://news.cnblogs.com/n/504623/" target="_blank">Vertu中国再发新机：1部换10部iPhone 6</a><br> ·  <a href="http://news.cnblogs.com/n/504622/" target="_blank">地球之水比太阳更古老</a><br> ·  <a href="http://news.cnblogs.com/n/504621/" target="_blank">入手国行Xbox One的N个理由 亮点在最后</a><br> ·  <a href="http://news.cnblogs.com/n/504620/" target="_blank">Adobe在中国为啥混不下去了？</a><br>» <a href="http://news.cnblogs.com/" title="IT新闻" target="_blank">更多新闻...</a></div></div>
<div id="google_ad_c2" class="c_ad_block">
<div id="div-gpt-ad-1410860226396-0" style="width:468px; height:60px;">
<script type="text/javascript">
try {
    if (enableGoogleAd) {
        googletag.cmd.push(function () { googletag.display('div-gpt-ad-1410860226396-0'); });
    } else {
        $('#div-gpt-ad-1346480159711-0').hide();
    }
} catch (e) { }
</script>
<div id="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0" name="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0" width="468" height="60" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom;"></iframe></div></div>
</div>
<div id="under_post_kb"><div class="itnews c_ad_block" id="kb_block"><b>最新知识库文章</b>:<br><div id="kb_recent"> ·  <a href="http://kb.cnblogs.com/page/504518/" target="_blank">构建高可伸缩性的WEB交互式系统（下）</a><br> ·  <a href="http://kb.cnblogs.com/page/504459/" target="_blank">谈谈网站测试中的AB测试方法</a><br> ·  <a href="http://kb.cnblogs.com/page/504453/" target="_blank">你在支配钱，还是钱在支配你？</a><br> ·  <a href="http://kb.cnblogs.com/page/504360/" target="_blank">关于技术变化方面的五种思想</a><br> ·  <a href="http://kb.cnblogs.com/page/504228/" target="_blank">图解SSL/TLS协议</a><br></div>» <a href="http://kb.cnblogs.com/" target="_blank">更多知识库文章...</a></div></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
$(function () {
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
    setTimeout(function () { incrementViewCount(cb_entryId); }, 200);
});
</script>
</div>

	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="blog-news"><div id="profile_block">昵称：<a href="http://home.cnblogs.com/u/afritxia2008/">Net.AfritXia</a><br>园龄：<a href="http://home.cnblogs.com/u/afritxia2008/" title="入园时间：2008-06-26">6年3个月</a><br>粉丝：<a href="http://home.cnblogs.com/u/afritxia2008/followers/">15</a><br>关注：<a href="http://home.cnblogs.com/u/afritxia2008/followees/">6</a><div id="p_b_follow"><a href="javascript:void(0);" onclick="cnblogs.UserManager.FollowBlogger(&#39;e542420b-63cf-dd11-9e4d-001cf0cd104b&#39;)">+加关注</a></div></div></div><script type="text/javascript">loadBlogNews();</script>
</div>

			<div id="calendar"><div id="blog-calendar" style=""><table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="日历">
	<tbody><tr><td colspan="7"><table class="CalTitle" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2008/06/01&#39;);return false;">&lt;</a></td><td align="center">2008年7月</td><td class="CalNextPrev" align="right"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2008/08/01&#39;);return false;">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" align="center" abbr="日" scope="col">日</th><th class="CalDayHeader" align="center" abbr="一" scope="col">一</th><th class="CalDayHeader" align="center" abbr="二" scope="col">二</th><th class="CalDayHeader" align="center" abbr="三" scope="col">三</th><th class="CalDayHeader" align="center" abbr="四" scope="col">四</th><th class="CalDayHeader" align="center" abbr="五" scope="col">五</th><th class="CalDayHeader" align="center" abbr="六" scope="col">六</th></tr><tr><td class="CalOtherMonthDay" align="center">29</td><td class="CalOtherMonthDay" align="center">30</td><td align="center">1</td><td align="center">2</td><td align="center">3</td><td align="center">4</td><td class="CalWeekendDay" align="center">5</td></tr><tr><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06.html"><u>6</u></a></td><td align="center">7</td><td align="center">8</td><td align="center">9</td><td align="center">10</td><td align="center">11</td><td class="CalWeekendDay" align="center">12</td></tr><tr><td class="CalWeekendDay" align="center">13</td><td align="center">14</td><td align="center">15</td><td align="center">16</td><td align="center">17</td><td align="center">18</td><td class="CalWeekendDay" align="center">19</td></tr><tr><td class="CalWeekendDay" align="center">20</td><td align="center">21</td><td align="center">22</td><td align="center">23</td><td align="center">24</td><td align="center">25</td><td class="CalWeekendDay" align="center">26</td></tr><tr><td class="CalWeekendDay" align="center">27</td><td align="center">28</td><td align="center">29</td><td align="center">30</td><td align="center">31</td><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td></tr><tr><td class="CalOtherMonthDay" align="center">3</td><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td><td class="CalOtherMonthDay" align="center">7</td><td class="CalOtherMonthDay" align="center">8</td><td class="CalOtherMonthDay" align="center">9</td></tr>
</tbody></table></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div>
			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn">
<div class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div id="widget_my_zzk" class="div_my_zzk"><input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk"></div>

</div>


<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>
<li><a href="http://www.cnblogs.com/afritxia2008/p/" title="我的博客的随笔列表">我的随笔</a></li><li><a href="http://www.cnblogs.com/afritxia2008/MyComments.html" title="我发表过的评论列表">我的评论</a></li><li><a href="http://www.cnblogs.com/afritxia2008/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li><li><a href="http://www.cnblogs.com/afritxia2008/RecentComments.html" title="我的博客的评论列表">最新评论</a></li><li><a href="http://www.cnblogs.com/afritxia2008/tag/" title="我的博客的标签列表">我的标签</a></li>
</ul>
<div id="itemListLin_con" style="display:none;">
<ul>

</ul>
</div>
</div>
<div class="catListTag">
<h3 class="catListTitle">我的标签</h3>
<ul>
<li><a href="http://www.cnblogs.com/afritxia2008/tag/linux/">linux</a>(4)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/php/">php</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/JAVA/">JAVA</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/ubuntu/">ubuntu</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/virtual%20box/">virtual box</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1/">架构设计</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/%E4%B8%89%E5%B1%82%E7%BB%93%E6%9E%84/">三层结构</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91/">游戏开发</a>(3)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/%E7%94%A8%E4%BE%8B/">用例</a>(2)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/%E7%95%99%E8%A8%80%E6%9D%BF/">留言板</a>(2)</li><li><a href="http://www.cnblogs.com/afritxia2008/tag/">更多</a></li>
</ul>
</div>
<div class="catListPostCategory">
<h3 class="catListTitle">随笔分类</h3>

<ul>

<li><a id="CatList_LinkList_0_Link_0" href="http://www.cnblogs.com/afritxia2008/category/252146.html">C#</a> </li>

<li><a id="CatList_LinkList_0_Link_1" href="http://www.cnblogs.com/afritxia2008/category/468015.html">JAVA(3)</a> </li>

<li><a id="CatList_LinkList_0_Link_2" href="http://www.cnblogs.com/afritxia2008/category/240311.html">Linux(3)</a> </li>

<li><a id="CatList_LinkList_0_Link_3" href="http://www.cnblogs.com/afritxia2008/category/252145.html">PHP(3)</a> </li>

<li><a id="CatList_LinkList_0_Link_4" href="http://www.cnblogs.com/afritxia2008/category/468014.html">WebGame(2)</a> </li>

<li><a id="CatList_LinkList_0_Link_5" href="http://www.cnblogs.com/afritxia2008/category/468013.html">架构设计(3)</a> </li>

<li><a id="CatList_LinkList_0_Link_6" href="http://www.cnblogs.com/afritxia2008/category/252147.html">设计模式</a> </li>

<li><a id="CatList_LinkList_0_Link_7" href="http://www.cnblogs.com/afritxia2008/category/468016.html">游戏开发(3)</a> </li>

<li><a id="CatList_LinkList_0_Link_8" href="http://www.cnblogs.com/afritxia2008/category/237197.html">职场技术小说(2)</a> </li>

</ul>

</div>

<div class="catListPostArchive">
<h3 class="catListTitle">随笔档案</h3>

<ul>

<li><a id="CatList_LinkList_1_Link_0" href="http://www.cnblogs.com/afritxia2008/archive/2013/04.html">2013年4月 (3)</a> </li>

<li><a id="CatList_LinkList_1_Link_1" href="http://www.cnblogs.com/afritxia2008/archive/2010/07.html">2010年7月 (1)</a> </li>

<li><a id="CatList_LinkList_1_Link_2" href="http://www.cnblogs.com/afritxia2008/archive/2010/06.html">2010年6月 (2)</a> </li>

<li><a id="CatList_LinkList_1_Link_3" href="http://www.cnblogs.com/afritxia2008/archive/2010/04.html">2010年4月 (3)</a> </li>

<li><a id="CatList_LinkList_1_Link_4" href="http://www.cnblogs.com/afritxia2008/archive/2010/03.html">2010年3月 (2)</a> </li>

<li><a id="CatList_LinkList_1_Link_5" href="http://www.cnblogs.com/afritxia2008/archive/2008/07.html">2008年7月 (1)</a> </li>

<li><a id="CatList_LinkList_1_Link_6" href="http://www.cnblogs.com/afritxia2008/archive/2008/06.html">2008年6月 (1)</a> </li>

</ul>

</div>

<div class="catListImageCategory">
<h3 class="catListTitle">相册</h3>

<ul>

<li><a id="CatList_LinkList_2_Link_0" href="http://www.cnblogs.com/afritxia2008/gallery/251450.html" rel="nofollow">Header</a> </li>

</ul>

</div>

<div id="recent_comments_wrap">
<div class="catListComment">
<h3 class="catListTitle">最新评论</h3>
	<div id="RecentCommentsBlock"><ul>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/afritxia2008/archive/2008/07/06/1236860.html#2962043">1. Re:使用CodeDom提高ORM性能</a></li>
    <li class="recent_comment_body">呵呵，将从数据库处理完后的数据直接转化为一个实体，然后把他们放到一个实体集里面去，这样是很方便的。</li>
    <li class="recent_comment_author">--(￣o￣) . z Z</li>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/afritxia2008/archive/2013/04/07/3006429.html#2844909">2. Re:打开潘多拉的魔盒——软件设计过程(3)——用例</a></li>
    <li class="recent_comment_body">楼主快更新啊!期待。。。。</li>
    <li class="recent_comment_author">--了唐愚人</li>
</ul>
</div>
</div>
</div><div id="topview_posts_wrap">
<div class="catListView">
<h3 class="catListTitle">阅读排行榜</h3>
	<div id="TopViewPostsBlock"><ul><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/06/27/1766026.html">1. PHP三层结构(上)——简单三层结构(5483)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/07/03/1770427.html">2. PHP三层结构(下)——PHP实现AOP(4522)</a></li><li><a href="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/使用CodeDom提高ORM性能 - Net.AfritXia - 博客园.htm">3. 使用CodeDom提高ORM性能(2654)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2008/06/27/1231070.html">4. 在线用户统计与命令模式(2564)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/04/04/1704158.html">5. 在VirtualBox中安装Ubuntu 8.04 Server(2)(2261)</a></li></ul></div>
</div>
</div><div id="topfeedback_posts_wrap">
<div class="catListFeedback">
<h3 class="catListTitle">评论排行榜</h3>
	<div id="TopFeedbackPostsBlock"><ul><li><a href="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/使用CodeDom提高ORM性能 - Net.AfritXia - 博客园.htm">1. 使用CodeDom提高ORM性能(13)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2008/06/27/1231070.html">2. 在线用户统计与命令模式(9)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/07/03/1770427.html">3. PHP三层结构(下)——PHP实现AOP(5)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/03/14/1685383.html">4. 抓取单词音节(3)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/06/26/1765955.html">5. 使用XDebug对PHP进行性能分析(2)</a></li></ul></div>
</div>
</div><div id="topdigg_posts_wrap">
<div class="catListView">
<h3 class="catListTitle">推荐排行榜</h3>
<div id="TopDiggPostsBlock"><ul><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/07/03/1770427.html">1. PHP三层结构(下)——PHP实现AOP(4)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/06/27/1766026.html">2. PHP三层结构(上)——简单三层结构(3)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2013/04/07/3002829.html">3. 打开潘多拉的魔盒——软件设计过程(1)——序(3)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2013/04/07/3006429.html">4. 打开潘多拉的魔盒——软件设计过程(3)——用例(2)</a></li><li><a href="http://www.cnblogs.com/afritxia2008/archive/2010/03/13/1684917.html">5. 版本控制(2)</a></li></ul></div>
</div></div></div><script type="text/javascript">loadBlogSideColumn();</script><iframe src="./使用CodeDom提高ORM性能 - Net.AfritXia - 博客园_files/container.htm" style="visibility: hidden; display: none;"></iframe>
			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2014 Net.AfritXia
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->


<iframe id="google_osd_static_frame_9561714851297" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;"></iframe></body></html>